﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace Taurus.Parking.CarPropertyBind
{
    public class CarCustomTypeDescriptor : CustomTypeDescriptor
    {
        public CarCustomTypeDescriptor(ICustomTypeDescriptor parent)
            : base(parent)
        { }

        public override PropertyDescriptorCollection GetProperties()
        {
            PropertyDescriptorCollection cols = base.GetProperties();

            PropertyDescriptor parkPD = cols["Park"];

            PropertyDescriptorCollection parkPD_child = parkPD.GetChildProperties();
            //扩展3个属性
            PropertyDescriptor[] array = new PropertyDescriptor[cols.Count + 3];

            cols.CopyTo(array, 0);

            array[cols.Count] = new SubPropertyDescriptor(parkPD, parkPD_child["OwnerName"], "Park_OwnerName");

            array[cols.Count + 1] = new SubPropertyDescriptor(parkPD, parkPD_child["MoneyMinute"], "Park_MoneyMinute");
            array[cols.Count + 2] = new SubPropertyDescriptor(parkPD, parkPD_child["Profit"], "Park_Profit");

            PropertyDescriptorCollection newcols = new PropertyDescriptorCollection(array);

            return newcols;           

        }     
    }
}
